package com.caochenlei.graph;

public class KruskalMSTTest {
    public static void main(String[] args) {
        EdgeWeightedGraph EWG = new EdgeWeightedGraph(8);
        EWG.addEdge(new Edge(4, 5, 0.35));
        EWG.addEdge(new Edge(4, 7, 0.37));
        EWG.addEdge(new Edge(5, 7, 0.28));
        EWG.addEdge(new Edge(0, 7, 0.16));
        EWG.addEdge(new Edge(1, 5, 0.32));
        EWG.addEdge(new Edge(0, 4, 0.38));
        EWG.addEdge(new Edge(2, 3, 0.17));
        EWG.addEdge(new Edge(1, 7, 0.19));
        EWG.addEdge(new Edge(0, 2, 0.26));
        EWG.addEdge(new Edge(1, 2, 0.36));
        EWG.addEdge(new Edge(1, 3, 0.29));
        EWG.addEdge(new Edge(2, 7, 0.34));
        EWG.addEdge(new Edge(6, 2, 0.40));
        EWG.addEdge(new Edge(3, 6, 0.52));
        EWG.addEdge(new Edge(6, 0, 0.58));
        EWG.addEdge(new Edge(6, 4, 0.93));

        KruskalMST mst = new KruskalMST(EWG);
        System.out.println("最小生成树的各边：");
        for (Edge e : mst.edges()) {
            System.out.println(e);
        }
        System.out.println("====================");
        System.out.println("最小生成树的权重：" + mst.weight());
    }
}
